package com.gm.hardwarelib.pin;

/**
 * Created by Mouse on 2017/7/29.
 */

public enum NanopcT3GPIO {

    GPIOA_BASE(0, "GPIOA_BASE"),

    GPIOB_BASE(32, "GPIOB_BASE"),

    GPIOC_BASE(64, "GPIOC_BASE"),

    GPIOD_BASE(96, "GPIOD_BASE"),

    GPIOE_BASE(128, "GPIOE_BASE"),

    GPIOALV(160, "GPIOALV");

    private int pin;
    private String name;

    NanopcT3GPIO(int pin, String name) {
        this.pin = pin;
        this.name = name;
    }

    public static NanopcT3GPIO valueOf(int pin) {
        for (NanopcT3GPIO v : NanopcT3GPIO.values()) {
            if (v.pin == pin) {
                return v;
            }
        }
        throw new IllegalArgumentException();
    }

    public static int pin(NanopcT3GPIO base, int offset) {
        return base.getPin() + offset;
    }

    public int getPin() {
        return pin;
    }

    public String getName() {
        return name;
    }
}
